#include "csapp.h"
#include "stdio.h"
#include "stdlib.h"
#include "semaphore.h"
volatile long cnt = 0;
void *thread(void *vargp){
	long i=0,niters=*( (long *)vargp );
	for(;i<niters;++i) { 
		+cnt;
	}
	return NULL;
}
int main(int argc,char **argv){
	long niters;
	pthread_t tid1,tid2;
	niters= atoi(argv[1]);
	Pthread_create(&tid1,NULL,thread,&niters);
	Pthread_create(&tid2,NULL,thread,&niters);
	Pthread_join(tid1,NULL);
	Pthread_join(tid2,NULL);
	if(cnt == niters+niters) printf("OK! cnt==%ld\n",cnt);
	else printf("BOOM! cnt==%ld\n",cnt);
	exit(0);
}
